/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-01-03 16:21:17
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-07-31 18:02:41
 * @FilePath: \cxl-admin\src\apis\finance\price.ts
 */
import axios from '../../axios/index'

/**
 * 套餐接口
 */
interface setMealInterface {
    amount?: number //套餐金额
    searchCount?: number //套餐次数
    id?: string //套餐id
    nameNumber?: number
}

/**
 * 定义新增价格参数接口
 */
interface dataInterface {
    id?: string //价格id
    name?: string //套餐名称
    singlePrice?: number //单笔价格
    type: number //储值类型（1.充值送查询次数；2.查询次数包；3.单笔）
    validity?: number //有效期
    storeStrategyDetailDTOS?: setMealInterface[] //套餐数据
}

/**
 * 创建价格接口
 * @param data dataInterface
 * @returns
 */
export const createPrice = (data: dataInterface) => {
    return axios({
        method: 'post',
        url: '/api/mall/store/strategy/add',
        data
    })
}

/**
 * 编辑价格接口
 * @param data
 * @returns
 */
export const editPrice = (data: dataInterface) => {
    return axios({
        method: 'post',
        url: '/api/mall/store/strategy/edit',
        data
    })
}

/**
 * 价格启用|禁用
 * @param id
 * @param status 状态（0.禁用；1.启用）
 * @param type 套餐类型（1.充值送查询次数；2.查询次数包；3.单笔）
 * @returns
 */
export const enablePrice = (id: string, status: number, type: number) => {
    return axios({
        method: 'post',
        url: '/api/mall/store/strategy/enable',
        data: {
            id,
            status,
            type
        }
    })
}

/**
 * 通过id查询价格信息
 * @param id
 * @returns
 */
export const getPriceById = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/mall/store/strategy/find-by-id',
        params: { id }
    })
}

/**
 * 获取套餐数据
 * @param type
 * @returns
 */
export const getSetMealInformation = (type: number) => {
    return axios({
        method: 'get',
        url: '/api/mall/store/strategy/findEnableStrategy',
        params: { type }
    })
}

/**
 * 查询价格分页接口
 */
interface pricePageIngetface {
    current: number //当前页
    size: number //每页数量
    type: number //套餐类型（1.充值送查询次数；2.查询次数包；3.单笔）
    status?: number //状态（0.禁用；1.启用）
}

/**
 * 查询分页
 * @param params
 * @returns
 */
export const pricePage = (params: pricePageIngetface) => {
    return axios({
        method: 'get',
        url: '/api/mall/store/strategy/list',
        params
    })
}

//产品价格删除
export const productPriceDelete = (id: string) => {
    return axios({
        method: 'post',
        url: '/api/mall/product/config/delete',
        data: { id }
    })
}
